package com.lxj.controller;

import com.lxj.anno.Log;
import com.lxj.domain.SysRole;
import com.lxj.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lxj
 * @date 2021/7/31 16:16
 * @Description:
 */
@RestController
@RequestMapping("sys/role")
@Api("角色管理")
public class SysRoleController {

    @Autowired
    private SysRoleService roleService;

    @GetMapping("list")
    @ApiOperation("加载所有的角色列表")
    @PreAuthorize("hasAuthority('sys:role:list')")
    @Log(operation = "加载所有的角色列表")
    public ResponseEntity<List<SysRole>> loadAllRole(){
        List<SysRole> list = roleService.list();
        return ResponseEntity.ok(list);
    }
}
